package com.tiza.xiaoyoubao.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.tianze.library.base.BaseFragment;
import com.tiza.xiaoyoubao.R;
import com.tiza.xiaoyoubao.app.UIHelper;
import com.tiza.xiaoyoubao.entity.BrowseCompleteInfo;
import com.tiza.xiaoyoubao.entity.BrowseConfirmInfo;
import com.tiza.xiaoyoubao.entity.BrowseDnTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.BrowseJDTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.BrowseMGJTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.BrowseMLSTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.BrowseOperateInfo;
import com.tiza.xiaoyoubao.entity.BrowseTMTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.BrowseTaskOrderInfo;
import com.tiza.xiaoyoubao.utils.DateUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mapple on 17/5/22.
 * 电脑浏览任务2
 */

public class BrowseDnTask2Fragment extends BaseFragment {
    @BindView(R.id.tv_sellerId)
    TextView tv_sellerId;
    //搜索价格
    @BindView(R.id.tv_cJPrice)
    TextView tv_cJPrice;
    //操作状态
    @BindView(R.id.tv_taskState)
    TextView tv_taskState;
    //商家要求
    @BindView(R.id.tv_sellerRequire)
    TextView tv_sellerRequire;
    @BindView(R.id.tv_time)
    TextView tv_time;
    //编号
    @BindView(R.id.tv_taskId)
    TextView tv_taskId;
    //买号
    @BindView(R.id.tv_buyerId)
    TextView tv_buyerId;
    //状态
    @BindView(R.id.tv_state)
    TextView tv_state;
    //完成状态
    @BindView(R.id.tv_taskCompleteState)
    TextView tv_taskCompleteState;
    //获得佣金
    @BindView(R.id.tv_getCommission)
    TextView tv_getCommission;
    @BindView(R.id.view1)
    View view1;
    @BindView(R.id.view2)
    View view2;
    Bundle args;
    private String state;
    private BrowseDnTaskOrderInfo browseDnTaskOrderInfo;
    private BrowseCompleteInfo browseCompleteInfo;
    private BrowseOperateInfo browseOperateInfo;
    private BrowseConfirmInfo browseConfirmInfo;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_browse_dn_task2;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        switch (state) {
            case "browseOperate":
                BrowseConfirm();
                break;
            case "confirm":
                BrowseOperate();
                break;
            case "browseComplate":
                BrowseComplate();
                break;
            case "browseDnTb":
                BrowseDnTb();
                break;
            default:
                break;
        }
    }


    @OnClick({R.id.view_go})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.view_go:
                UIHelper.showBrowseDnTaskDetail2(mActivity,args);
                break;
            default:
                break;
        }
    }
    public void BrowseComplate() {
        browseCompleteInfo = (BrowseCompleteInfo) args.getSerializable("info");
        tv_sellerId.setText("商家ID:" + browseCompleteInfo.getUserId());
        tv_cJPrice.setText(browseCompleteInfo.getMobilePrice());
        tv_taskState.setText("任务状态：已完成");
        tv_state.setText("已完成");
        tv_taskCompleteState.setText("已完成");
        if (browseCompleteInfo.getRemarks().equals(" ")) {
            tv_sellerRequire.setText("商家要求:此商家无其他要求");
        } else {
            tv_sellerRequire.setText("商家要求:" + browseCompleteInfo.getRemarks());
        }
        tv_getCommission.setText(DateUtils.formateRate(browseCompleteInfo.getBaseCmi()));
        view2.setBackgroundColor(getResources().getColor(R.color.steel_blue));
    }

    public void BrowseOperate() {
        browseOperateInfo = (BrowseOperateInfo) args.getSerializable("info");
        tv_sellerId.setText("商家ID:" + browseOperateInfo.getUserId());
        tv_cJPrice.setText(browseOperateInfo.getMobilePrice());
        tv_taskState.setText("任务状态：待操作");
        tv_state.setText("未完成");
        tv_taskCompleteState.setText("未完成");
        if (browseOperateInfo.getRemarks().equals(" ")) {
            tv_sellerRequire.setText("商家要求:此商家无其他要求");
        } else {
            tv_sellerRequire.setText("商家要求:" + browseOperateInfo.getRemarks());
        }
        tv_getCommission.setText(DateUtils.formateRate(browseOperateInfo.getBaseCmi()));
    }

    public void BrowseConfirm() {
        browseConfirmInfo = (BrowseConfirmInfo) args.getSerializable("info");
        tv_sellerId.setText("商家ID:" + browseConfirmInfo.getUserId());
        tv_cJPrice.setText(browseConfirmInfo.getMobilePrice());
        tv_taskState.setText("任务状态：待确认");
        tv_state.setText("未完成");
        tv_taskCompleteState.setText("未完成");
        if (browseConfirmInfo.getRemarks().equals(" ")) {
            tv_sellerRequire.setText("商家要求:此商家无其他要求");
        } else {
            tv_sellerRequire.setText("商家要求:" + browseConfirmInfo.getRemarks());
        }
        tv_getCommission.setText(DateUtils.formateRate(browseConfirmInfo.getBaseCmi()));
    }

    public void BrowseDnTb() {
        browseDnTaskOrderInfo = (BrowseDnTaskOrderInfo) args.getSerializable("info");
        tv_sellerId.setText("商家ID:" + browseDnTaskOrderInfo.getUserId());
        tv_cJPrice.setText(browseDnTaskOrderInfo.getMobilePrice());
        tv_taskState.setText("任务状态：待操作");
        tv_state.setText("未完成");
        tv_taskCompleteState.setText("未完成");
        if (browseDnTaskOrderInfo.getRemarks().equals(" ")) {
            tv_sellerRequire.setText("商家要求:此商家无其他要求");
        } else {
            tv_sellerRequire.setText("商家要求:" + browseDnTaskOrderInfo.getRemarks());
        }
        tv_getCommission.setText(DateUtils.formateRate(browseDnTaskOrderInfo.getBaseCmi()));
    }
}
